package com.atguigu.tingshu.user.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WeChatMpConfig {

    @Autowired
    private  WeChatConstantProperties weChatConstantProperties;
    @Bean
    public WxMaService  wxMaservice(){

        WxMaDefaultConfigImpl wxMaDefaultConfig = new WxMaDefaultConfigImpl();
        wxMaDefaultConfig.setAppid(weChatConstantProperties.getAppId());
        wxMaDefaultConfig.setSecret(weChatConstantProperties.getAppSecret());
        wxMaDefaultConfig.setMsgDataFormat("JSON");

        WxMaService wxMaService = new WxMaServiceImpl();

        wxMaService.setWxMaConfig(wxMaDefaultConfig);

        return  wxMaService;
    }
}
